<template>
  <div id="space-analyze-page">
    <div class="title-bar">
      <h2 class="title-font">
        空间图库分析 -
        <span v-if="queryAll"> 全部空间 </span>
        <span v-else-if="queryPublic"> 公共图库 </span>
        <span v-else>
          <a :href="`/space/${spaceId}`" target="_blank">{{ spaceId }}</a>
        </span>
      </h2>
    </div>
    <a-row :gutter="[24, 24]">
      <!-- 空间使用分析 -->
      <a-col :xs="24" :md="12">
        <!-- 添加组件容器样式类 -->
        <div class="analyze-card">
          <SpaceUsageAnalyze :spaceId="spaceId" :queryAll="queryAll" :queryPublic="queryPublic" />
        </div>
      </a-col>
      <!-- 空间分类分析 -->
      <a-col :xs="24" :md="12">
        <div class="analyze-card">
          <SpaceCategoryAnalyze :spaceId="spaceId" :queryAll="queryAll" :queryPublic="queryPublic" />
        </div>
      </a-col>
      <!-- 标签分析 -->
      <a-col :xs="24" :md="12">
        <div class="analyze-card">
          <SpaceTagsAnalyze :spaceId="spaceId" :queryAll="queryAll" :queryPublic="queryPublic" />
        </div>
      </a-col>
      <!-- 图片大小分段分析 -->
      <a-col :xs="24" :md="12">
        <div class="analyze-card">
          <SpaceSizeAnalyze :spaceId="spaceId" :queryAll="queryAll" :queryPublic="queryPublic" />
        </div>
      </a-col>
      <!-- 用户上传行为分析 -->
      <a-col :xs="24" :md="12">
        <div class="analyze-card">
          <SpaceUserAnalyze :spaceId="spaceId" :queryAll="queryAll" :queryPublic="queryPublic" />
        </div>
      </a-col>
      <!-- 空间使用排行分析 -->
      <a-col :xs="24" :md="12">
        <div class="analyze-card">
          <SpaceRankAnalyze
            v-if="isAdmin"
            :spaceId="spaceId"
            :queryAll="queryAll"
            :queryPublic="queryPublic"
          />
        </div>
      </a-col>
    </a-row>
  </div>
</template>

<script setup lang="ts">
// 原有脚本逻辑保持不变
import SpaceUsageAnalyze from '@/components/analyze/SpaceUsageAnalyze.vue'
import SpaceCategoryAnalyze from '@/components/analyze/SpaceCategoryAnalyze.vue'
import SpaceTagsAnalyze from '@/components/analyze/SpaceTagsAnalyze.vue'
import SpaceSizeAnalyze from '@/components/analyze/SpaceSizeAnalyze.vue'
import SpaceUserAnalyze from '@/components/analyze/SpaceUserAnalyze.vue'
import { useRoute } from 'vue-router'
import { computed } from 'vue'
import SpaceRankAnalyze from '@/components/analyze/SpaceRankAnalyze.vue'
import { useLoginUserStore } from '@/stores/userLogin'

const route = useRoute()

const spaceId = computed(() => {
  return route.query?.spaceId as string
})

const queryAll = computed(() => {
  return !!route.query?.queryAll
})

const queryPublic = computed(() => {
  return !!route.query?.queryPublic
})

const loginUserStore = useLoginUserStore()
const loginUser = loginUserStore.loginUser

const isAdmin = computed(() => {
  return loginUser.userRole === 'admin'
})
</script>

<style scoped>
/* 容器样式保持不变 */
#space-analyze-page {
  background-color: rgba(255, 255, 255, 0.68);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  border-radius: 8px;
  padding: 20px;
  margin: 0 auto;
  box-sizing: border-box;
}

/* 标题栏样式保持不变 */
.title-bar {
  min-height: 60px;
  background-color: #ffffff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  border-radius: 8px;
  transition: all 0.3s ease;
  cursor: default;
  font-weight: bold !important;
  margin-bottom: 20px;
  padding: 10px 20px;
  box-sizing: border-box;
}

.title-font {
  font-weight: bold;
  margin: 0;
  line-height: 40px;
}

/* 新增：组件卡片样式 - 阴影和悬浮效果 */
.analyze-card {
  /* 基础阴影效果 */
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.08),
    0 1px 3px rgba(0, 0, 0, 0.1);
  /* 圆角 */
  border-radius: 12px;
  /* 内边距 */
  padding: 16px;
  /* 背景色 */
  background-color: rgba(255, 255, 255, 0.68);
  /* 过渡动画 - 确保悬浮效果平滑 */
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  /* 避免内容溢出 */
  overflow: hidden;
}

/* 鼠标划入上浮效果 */
.analyze-card:hover {
  /* 上浮5px */
  transform: translateY(-5px);
  /* 加深阴影，增强层次感 */
  box-shadow:
    0 12px 20px rgba(0, 0, 0, 0.12),
    0 6px 6px rgba(0, 0, 0, 0.08);
}
</style>
